package com.yanqu.road.entity.activity.turtle.data;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author : Cxp
 * @Time : 2024-09-09
 * @Description : 乌龟对对碰-游戏实体类
 */

public class TurtleGame {
    private int luckyColor; // 当前局幸运色
    private int templateId; // 模板ID
    private int templateIdx; // 模板索引
    private int cardNum; // 卡包数量
    private String startLayout; // 当前轮开始的布局
    private String endLayout; // 当前轮结束的布局
    private List<Integer> colors; // 颜色映射
    private Map<Integer, String> roundResult; // 当前轮碰撞结果
    private Map<Integer, Map<Integer, Integer>> totalResult; // 累计碰撞结果 颜色->(类型->数量)

    public int getLuckyColor() {
        return luckyColor;
    }

    public void setLuckyColor(int luckyColor) {
        this.luckyColor = luckyColor;
    }

    public int getTemplateId() {
        return templateId;
    }

    public void setTemplateId(int templateId) {
        this.templateId = templateId;
    }

    public int getTemplateIdx() {
        return templateIdx;
    }

    public void setTemplateIdx(int templateIdx) {
        this.templateIdx = templateIdx;
    }

    public List<Integer> getColors() {
        if (colors == null) {
            return new ArrayList<>();
        }
        return colors;
    }

    public void setColors(List<Integer> colors) {
        this.colors = colors;
    }

    public int getCardNum() {
        return cardNum;
    }

    public void setCardNum(int cardNum) {
        this.cardNum = cardNum;
    }

    public String getStartLayout() {
        if (startLayout == null) {
            return "";
        }
        return startLayout;
    }

    public void setStartLayout(String startLayout) {
        this.startLayout = startLayout;
    }

    public String getEndLayout() {
        if (endLayout == null) {
            return "";
        }
        return endLayout;
    }

    public void setEndLayout(String endLayout) {
        this.endLayout = endLayout;
    }

    public Map<Integer, String> getRoundResult() {
        if (roundResult == null) {
            return new HashMap<>();
        }
        return roundResult;
    }

    public void setRoundResult(Map<Integer, String> roundResult) {
        this.roundResult = roundResult;
    }

    public Map<Integer, Map<Integer, Integer>> getTotalResult() {
        if (totalResult == null) {
            return new HashMap<>();
        }
        return totalResult;
    }

    public void setTotalResult(Map<Integer, Map<Integer, Integer>> totalResult) {
        this.totalResult = totalResult;
    }

    public TurtleGame clone() {
        TurtleGame res = new TurtleGame();

        res.setLuckyColor(this.getLuckyColor());
        res.setTemplateId(this.getTemplateId());
        res.setTemplateIdx(this.getTemplateIdx());
        res.setCardNum(this.getCardNum());
        res.setStartLayout(this.getStartLayout());
        res.setEndLayout(this.getEndLayout());
        res.setColors(this.getColors());
        res.setRoundResult(new HashMap<>(this.getRoundResult()));

        Map<Integer, Map<Integer, Integer>> tmpTotalResult = new HashMap<>();
        for (Map.Entry<Integer, Map<Integer, Integer>> kv : this.getTotalResult().entrySet()) {
            int key = kv.getKey();
            if (!tmpTotalResult.containsKey(key)) {
                tmpTotalResult.put(key, new HashMap<>(kv.getValue()));
            }
        }
        res.setTotalResult(tmpTotalResult);

        return res;
    }

    public void copy(TurtleGame data) {
        this.setLuckyColor(data.getLuckyColor());
        this.setTemplateId(data.getTemplateId());
        this.setTemplateIdx(data.getTemplateIdx());
        this.setCardNum(data.getCardNum());
        this.setStartLayout(data.getStartLayout());
        this.setEndLayout(data.getEndLayout());
        this.setColors(data.getColors());
        this.setRoundResult(data.getRoundResult());
        this.setTotalResult(data.getTotalResult());
    }
}
